<?php
/* sidebar.php */

?>

		<div id="right_sidebar">
			<img class="profile-pic" border="1px" src="uploads/
				<?php
					if (file_exists("uploads/" . md5($_SESSION['id'].$_SESSION['username']).'.png'))
				    {
				      echo md5($_SESSION['id'].$_SESSION['username']);
				    }
				    else
				    {
				      echo 'zombie';
				    }
					
				?>
			.png" width="169" height="169">
			<h2><?php echo $_SESSION['firstname'].'<br>'.$_SESSION['lastname']; ?> </h2>
			<hr>
			<h2>My Houses</h2>
			<?php
				$query = "SELECT * FROM houses
							JOIN houses_users ON houses.id = houses_users.house_id
							WHERE houses_users.user_id = " . $_SESSION['id'];
				$results = mysql_query($query);
				while($row = mysql_fetch_array($results))
				{
					echo "<p><a href=\"houses.php?id=".$row['house_id']."\">".$row['name']."</a><p>";
					echo "<h4><a href=\"addbill.php?house_id=".$row['house_id']."\">Add a bill</a><h4><br>";
				}
			?>
			<h3><a href="createhouse.php">Create House</a></h3>
		</div>